package com.weyoung.common.consatant.result;

import com.weyoung.common.enums.ResponseCodeEnum;
import lombok.Data;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

@Data
public class PageResult<T> implements Serializable {

    /**
     * 总条数
     */
    private long count;

    /**
     * 数据列表
     */
    private List<T> list;

    /**
     * info
     */
    private String info;

    public PageResult(int code, String message, long count, List<T> list) {
        this.count = count;
        this.list = list;
    }

    public PageResult(int code, String message, long count, List<T> list, String info) {
        this.count = count;
        this.list = list;
        this.info = info;
    }


    /**
     * 返回成功
     *
     * @param count 总条数
     * @param list  数据
     */
    public static <T> PageResult<T> of(long count, List<T> list) {
        return new PageResult<>(ResponseCodeEnum.SUCCESS.getCode(), ResponseCodeEnum.SUCCESS.getDesc(), count, list);
    }

    /**
     * 返回成功 用于专业优先以及院校优先
     *
     * @param count 总条数
     * @param list  数据
     */
    public static <T> PageResult<T> of2(long count, List<T> list, String info) {
        return new PageResult<>(ResponseCodeEnum.SUCCESS.getCode(), ResponseCodeEnum.SUCCESS.getDesc(), count, list, info);
    }
    /**
     * 返回成功 用于院校优先-未使用
     *
     * @param count 总条数
     * @param list  数据
     */
    public static <T> PageResult<T> of3(long count, List<T> list, ArrayList<Integer> cwbd) {
        return new PageResult<>(ResponseCodeEnum.SUCCESS.getCode(), ResponseCodeEnum.SUCCESS.getDesc(), count, list);
    }

    /**
     * 返回空
     */
    public static <T> PageResult<T> empty() {
        return new PageResult<>(ResponseCodeEnum.SUCCESS.getCode(), ResponseCodeEnum.SUCCESS.getDesc(), 0, new ArrayList<>());
    }
}